fix: reject non-finite values from digit overflow path#10
Merged
Conversation
Scientific notation already rejected ±inf/NaN, but integer_overflow accepted ~310+ digit magnitudes as IEEE infinity. Guard digit accumulation and finalize paths (including fraction) so parse fails instead of storing non-JSON numeric values. Co-authored-by: Kaius Ruokonen <ruoka@users.noreply.github.com>
ruoka
marked this pull request as ready for review
July 20, 2026 12:34
ruoka
added a commit
that referenced
this pull request
Jul 21, 2026
Scientific notation already rejected ±inf/NaN, but integer_overflow accepted ~310+ digit magnitudes as IEEE infinity. Guard digit accumulation and finalize paths (including fraction) so parse fails instead of storing non-JSON numeric values. Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Kaius Ruokonen <ruoka@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug and impact
json::parseaccepted digit-only magnitudes beyond the IEEE-754 double range (~310+ digits, e.g.1followed by 400 zeros) and stored±infinityas a number value.Impact: silent acceptance of non-JSON numeric values; downstream
stringifycan emit non-JSON (inf/-inf), and callers treating parsed numbers as finite doubles get corrupted data.Root cause
The scientific-notation path already rejected non-finite
powresults withstd::isfinite, butdecoder::integer_overflow(used when int64 overflows into float digit accumulation) did not. Multiplyingm_numberby 10 across enough digits overflows double to±inf, which was then passed tom_builder.value.Fix
integer_overflowinteger_overflowandfractions(covers overflow → fraction)Validation
DigitOverflowToInfinityRejectedcovering positive, negative, and fractional oversized digit strings./tools/CB.sh debug test --tags='\[xson\]'— 403/403 passed